#

| Chapter 11 The Lessons of History |

## 11.6 Using !$ for Safety with Wildcards

We all know about using ls before a wildcarded rm to make sure that we're only deleting what we want. But that doesn't really solve the problem: you can type `ls a*` and then mistakenly type `rm s*` with bad consequences - it's just a minor slip of your finger. But what will always work, if you're a csh or bash user, is:

>     % ls a*
>     a1 a2 a3
>     % rm !$

(`ls -d a*` (16.8) will make less output if any subdirectory names match the wildcard.)

Using the history mechanism to grab the previous command's arguments is a good way to prevent mistakes.

- ML

11.5 My Favorite Is ^^ |  | 11.7 History Substitutions